import { request } from '@inbiz/utils';
const version = InbizConfig.API_VERSION
// 获取分组列表数据
export const getProcessGroupList = (params?: any) => {
  return request('/edoc2Flow-web/process/manageMent/getProcessGroup', {
    params,
  });
};

// 添加分组
export const addGroupEntity = (params: any) => {
  return request('/edoc2Flow-web/process/manageMent/saveOrUpdateProcessGroup', {
    method: 'POST',
    data: {
      appId: params.appId,
      groupId: params.groupId,
      groupName: params.groupName,
      isShow: params.isShow,
      mark: params.mark,
    },
  });
};

// 删除分组
export const deleteProcessGroupById = (params: { groupId: any }) => {
  return request('/edoc2Flow-web/process/manageMent/deleteProcessGroup', {
    method: 'POST',
    params: {
      groupId: params.groupId,
    },
  });
};

// 拖拽排序分组

export const SortProcessGroup = (params: any) => {
  return request('/edoc2Flow-web/process/manageMent/dragSortProcessGroup', {
    method: 'POST',
    data: params,
  });
};

// 按钮功能区

// 移动接口
export const moveProcess = (params: any) => {
  return request('/edoc2Flow-web/process/manageMent/moveProcess', {
    method: 'POST',
    data: {
      groupId: params.groupId,
      handelUserId: params.handelUserId,
      ids: params.ids,
    },
    appId: params?.appId
  });
};
//复制接口
export const copyProcess = (params: any) => {
  return request('/edoc2Flow-web/process/manageMent/copyProcess', {
    method: 'POST',
    requestType: 'form',
    data: {
      appId: params.appId,
      formType: params.formType,
      groupId: params.groupId,
      groupName: params.groupName,
      isShow: params.isShow,
      name: params.name,
      processId: params.processId,
      mark: params.mark
    },
    appId: params?.appId
  });
};

// 获取表格数据
export const getTableList = (params: {
  groupId: any;
  pageIndex: number;
  pageSize: number;
  searchContext: string;
}) => {
  return request('/edoc2Flow-web/process/manageMent/getProcessList', {
    params
  });
};

// 编辑表单后保存
export const saveProcessManage = (params: {
  formKey: string;
  groupId: string;
  id: string;
  name: string;
  pageKey: string;
  pcPageKey: string;
  potentialStartName: string;
  potentialStarterId: string;
  potentialType: number;
  proLcon: string;
  sort: number;
  mark?: string;
  descript: string;
  groupName: string;
}) => {
  return request('/edoc2Flow-web/process/manageMent/saveOrupdateProcess', {
    method: 'POST',
    data: params,
  });
};

// 获取设置变量表格数据
export const getvariateList = (params: {
  processDefinitionId: string;
  processId: string;
  pageSize: number;
}) => {
  return request('/edoc2Flow-web/process/manageMent/getProcessVar', {
    params: {
      processDefinitionId: params.processDefinitionId,
      processId: params.processId,
      pageSize: params.pageSize,
    },
  });
};

// 保存设置变量
export const saveVariate = (params: any) => {
  return request('/edoc2Flow-web/process/manageMent/saveOrUpdateProcessVar', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
};

// 发布
export const publishProcess = (params: { key: any }) => {
  return request('/edoc2Flow-web/process/manageMent/processRelease', {
    method: 'POST',
    data: {
      key: params.key,
      isproce: true,
    },
  });
};

// 下架
export const offProcess = (params: { key: String }) => {
  return request('/edoc2Flow-web/process/manageMent/processOffShelf', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
};

// 关闭
export const closeProcess = (params: { key: String }) => {
  return request('/edoc2Flow-web/process/manageMent/processClosure', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
};

// 删除
export const deleteProcessGroup = (params: { processId: String }) => {
  return request('/edoc2Flow-web/process/manageMent/processDelete', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
};

// 获取流程绑定页面的控件
export const getPageDetails = (params: { processKey: string }) => {
  return request('/edoc2Flow-web/process/manageMent/getPageDetails', {
    params,
  });
};

// 获取原数据
export const loadDetail = (params: { outId: string; siteOutId: string; appId: string }) => {
  return request('/inbiz/api/services/front/engines/v3/page/loadDetail', {
    params,
    appId: params.appId,
  });
};

// 获取表单分组列表数据
export const getFormGroupData = (params?: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPageGroup/treeList`, {
    method: 'GET',
    params,
    appId: params.appId
  });
};

// 获取站点列表
export async function getAppList() {
  return request(
    `/inbiz/api/services/engines/v${InbizConfig.API_VERSION}/app/pagedList`,
    {
      params: {
        SkipCount: 0,
        MaxResultCount: 1000,
        keyWords: '',
      },
    },
  );
}

// 获取表单基本信息
export async function getFormInfo(params: { appId: string, outId?: string, route?: string }) {
  return request(`/inbiz/api/services/wfpage/v${InbizConfig.API_VERSION}/wfPage/pageBasicInfo`, {
    method: 'GET',
    params: {
      outId: params.outId,
      route: params.route
    },
    appId: params.appId
  });
}

// 获取多语言组件列表
export async function getLangComList(params: any) {
  return request(`/inbiz/api/services/languagengine/v${InbizConfig.API_VERSION}/componentLanguage/components`, {
    method: 'GET',
    params,
    appId: params.appId
  });
}